package com.undsf.domainganker;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Arathi on 2015/4/25.
 */
public class DomainInfo {
    public static final int DOMAIN_STATUS_NULL = 0;
    public static final int DOMAIN_STATUS_DELETED = 1; //已删除，未检测
    public static final int DOMAIN_STATUS_PRE_RELEASE = 2; //即将删除，未检测

    public static final int DOMAIN_STATUS_UNOWNED = 11; //无主的 确定已删除

    public static Map<Integer, String> DomainStatus;

    static {
        DomainStatus = new HashMap<Integer, String>();
        DomainStatus.put(DOMAIN_STATUS_DELETED, "已删除");
        DomainStatus.put(DOMAIN_STATUS_PRE_RELEASE, "即将删除");
    }

    private String domainName; //域名
    private int status; //当前状态
    private Date deleteDate; //删除日期

    public DomainInfo(String dn){
        domainName = dn;
        status = DOMAIN_STATUS_NULL;
        deleteDate = null;
    }

    public DomainInfo(String dn, int st, Date dd){
        domainName = dn;
        status = st;
        deleteDate = dd;
    }

    public DomainInfo(String dn, int st, String ddStr){
        domainName = dn;
        status =st;
        //将字符串转为Date
        deleteDate = null;
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            deleteDate = sdf.parse(ddStr);
        }
        catch (ParseException e){
            e.printStackTrace();
        }
    }

    @Override
    public String toString(){
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = "未知";
        try{
            dateStr = sdf.format(deleteDate);
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return "域名："+domainName+"  过期时间："+dateStr+"  当前状态："+DomainStatus.get(status);
    }

    public String getDomainName() {
        return domainName;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Date getDeleteDate() {
        return deleteDate;
    }
}
